# -*- coding:UTF-8 -*-
from cmdb.models import ApprovalProcessLog

def exist_approval_process_log(apply_id):
    count = ApprovalProcessLog.objects.filter(apply_id=apply_id).count()
    if count > 0:
        return True
    return False

def add_approval_process_log(apply_id):
    apInfo = ApprovalProcessLog(apply_id=apply_id,approval_man='qianbo',status=0)
    apInfo.save()
    apInfo = ApprovalProcessLog(apply_id=apply_id,approval_man='liuchunbo',status=0)
    apInfo.save()

def get_approval_process_log(apply_id):
    pRes = ApprovalProcessLog.objects.filter(apply_id=apply_id).order_by('id')
    return pRes

def get_apply_id_approval_process(id):
    pRes = ApprovalProcessLog.objects.get(id=id)
    return pRes.apply_id

def update_approval_process_log(id,status,cursor):
    sql = 'update approval_process_log set status = ' + status + ' where id=' + id
    cursor.execute(sql)